import Circle from './Circle.vue';
import { render, h } from 'vue';


/* 虚拟节点 */
let instance: any = null;
const instances: Array<any> = [];
export const createCircle = (options: { color?: string, left: string, top: string }) => {

  if (Object.prototype.toString.call(options) !== '[object Object]') {
    throw new Error('options 的类型必须为一个对象！');
  }
  // 创建容器
  const container = document.createElement('div');

  // 创建虚拟节点
  instance = h(Circle, options);
  instances.push(instance);
  // 渲染真实节点
  render(instance, container);

  setTimeout(() => {
    instances[0].component.props.isDestory = true;
    instances.shift();
  }, 1000);

}
